﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ECONTACT.Bussiness;
using ECONTACT.DataLayer;
using System.Data;
using System.Windows.Forms;
using DevComponents.DotNetBar.Controls;
using DevComponents.Editors.DateTimeAdv;

namespace ECONTACT.Controller
{
    public class HanhKiemCtrl
    {
        HanhKiemData m_HanhKiemData = new HanhKiemData();

        #region Hien thi ComboBox
        public void HienThiComboBox(ComboBoxEx comboBox)
        {
            comboBox.DataSource = m_HanhKiemData.LayDsHanhKiem();
            comboBox.DisplayMember = "MaHK";
            comboBox.ValueMember = "MaHK";
        }
        #endregion

        #region Do du lieu vao DataGridView

        public void HienThi(DataGridViewX dGV,
                            TextBoxX txtMaHK,
                            TextBoxX txtTenHK)
        {
            BindingSource bS = new BindingSource();
            bS.DataSource = m_HanhKiemData.LayDsHanhKiem();

            DataTable dT = m_HanhKiemData.LayDsHanhKiem();

            txtMaHK.DataBindings.Clear();
            txtMaHK.DataBindings.Add("Text", bS, "MaHK");

            txtTenHK.DataBindings.Clear();
            txtTenHK.DataBindings.Add("Text", bS, "TenHK");

            dGV.DataSource = bS;
        }
        #endregion

        public void LuuHanhKiem(String Ten)
        {
            m_HanhKiemData.LuuHanhKiem(Ten);
        }

        public void UpdateHanhKiem(String MaHK, String Ten)
        {
            m_HanhKiemData.UpdateHanhKiem(MaHK, Ten);
        }

        public void DeleteHanhKiem(String MaHK)
        {
            m_HanhKiemData.DeleteHanhKiem(MaHK);
        }
    }
}
